<?php

namespace Home\Controller;

use Business\StrategyFactory;
use Common\Controller\BaseController;


class HomeController extends BaseController
{
    public function index()
    {
        $model = D('VUserNotice');
        $search_key = $_POST['search_key'];
        $status = $_POST['search_status'];
        $user_id = $this->current_user['id'];
        $list = $model->get_list($user_id, null, null, 1, 6);
        $this->assign('notice_list', $list[0]);

//        echo $current_user['role'];
//        exit();
        switch ($this->current_user['role']) {
            case 1:
                $this->setrole1();
                break;
            case 2:
                $this->setrole2();
                break;
            case 3:
                $this->setrole3();
                break;
            default:
        }

        $this->display();
    }

    private function setrole1()
    {
        $model = D('Task');

        $task_type = 0;
        $status = 1;
        $user_id = $this->current_user['id'];
        $list = $model->get_list(null, $status, $task_type, 1, 6);

        $this->assign('task_list1', $list[0]);

        $task_type = 1;
        $list = $model->get_list(null, $status, $task_type, 1, 6);

        $this->assign('task_list2', $list[0]);
    }

    private function setrole2()
    {
        $model = D('Task');

        $task_type = 0;
        $status = 1;
        $user_id = $this->current_user['id'];
        $list = $model->get_list(null, $status, $task_type, 1, 6);

        $this->assign('task_list1', $list[0]);

        $task_type = 1;
        $list = $model->get_list(null, $status, $task_type, 1, 6);

        $this->assign('task_list2', $list[0]);
    }

    private function setrole3()
    {
        $task_type = 0;
        $model = D('VUserTask');

        $status = array('0', '1');
        $user_id = $this->current_user['id'];
        $list = $model->get_list($user_id, null, $status, $task_type, null, 0, 0, 1, 6);

        $this->assign('task_list1', $list[0]);

//        $status = array('2', '3', '4');
        $task_type = 1;
        $list = $model->get_list($user_id, null, $status, $task_type, null, 0, 0, 1, 6);

        $this->assign('task_list2', $list[0]);
    }
}